const app = getApp();
import { getStorage } from "../../../utils/localStorage"
import { favoriteLikes_list } from "../../../api/my"
import { baseUrl } from "../../../api/request"
Page({
    data: {
        navData: {
            level: 2,
            title: "获赞与收藏"
        },
        imgUrl: null,
        user: null,
        list: [],
        navMargin: app.globalData.navHeight + app.globalData.navTop,
    },
    onLoad(options) {
        this.setData({
            user: getStorage("user"),
            imgUrl: baseUrl
        });
        this.getList();
    },
    onShow() {

    },
    //获取获赞与收藏列表数据
    getList() {
        favoriteLikes_list({ userId: this.data.user.id }).then(res => {
            if (!res.data.data || res.data.data.length === 0) {
                this.setData({
                    list: []
                });
            } else {
                res.data.data.forEach(item => {
                    item.imageScale = item.imageScale.split(",");
                });
                this.setData({
                    list: res.data.data,
                });
            };
            console.log(this.data.list, '获赞与收藏');
        });
    },
    //列表点击事件
    listTap(e) {
        const item = e.currentTarget.dataset.item;
        wx.navigateTo({
            url: '/pagesShouYe/pages/listDetail/index?id=' + item.id,
        })
    },
    onReady() {

    },


    /**
     * 生命周期函数--监听页面隐藏
     */
    onHide() {

    },

    /**
     * 生命周期函数--监听页面卸载
     */
    onUnload() {

    },

    /**
     * 页面相关事件处理函数--监听用户下拉动作
     */
    onPullDownRefresh() {

    },

    /**
     * 页面上拉触底事件的处理函数
     */
    onReachBottom() {

    },

    /**
     * 用户点击右上角分享
     */
    onShareAppMessage() {

    }
})